#ifndef __MSG_H_
#define __MSG_H_

typedef enum msg_type
{
	M_GetJPEG = 0,
    M_SendHeartBeat = 1,
    M_SendParameter = 2
}msg_t;

#define MSG_HDR_LEN 12
#define MIN_MSG_LEN MSG_HDR_LEN
#define MSG_MAGIC       0xD38A9F74

#define BUFFER_LEN 4096
typedef struct _cfg_msg
{
	msg_t          type;
	unsigned int   magic;
	int            len;
	char           body[1024*1024];
	_cfg_msg() {
		magic = MSG_MAGIC;
	}
	_cfg_msg(msg_t t) {
		type = t;
		magic = MSG_MAGIC;
	}
	void Init(msg_t t) {
		type = t;
		magic = MSG_MAGIC;
	}
	bool Isvalid() { return (MSG_MAGIC == magic && len >= MSG_HDR_LEN); }

	const char* typestr() {
		switch (type)
		{
		case M_GetJPEG: return "M_GetJPEG";
		case M_SendHeartBeat: return "M_SendHeartBeat";
		case M_SendParameter: return "M_SendParameter";
		default:
			break;
		}
		return "Invalid MSG";
	}
}cfg_msg;

#endif
